// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.randomizedWorld.randomizedVehicleStory;

import java.util.ArrayList;
import zombie.characters.IsoZombie;
import zombie.characters.BodyDamage.BodyPartType;
import zombie.core.Rand;
import zombie.iso.IsoChunk;
import zombie.iso.IsoDirections;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoMetaGrid;
import zombie.iso.Vector2;
import zombie.vehicles.BaseVehicle;

public final class RVSAmbulanceCrash extends RandomizedVehicleStoryBase {
    public RVSAmbulanceCrash() {
        this.name = "Ambulance Crash";
        this.minZoneWidth = 5;
        this.minZoneHeight = 7;
        this.setChance(5);
    }

    @Override
    public void randomizeVehicleStory(IsoMetaGrid.Zone zone, IsoChunk chunk) {
        this.callVehicleStorySpawner(zone, chunk, 0.0F);
    }

    @Override
    public boolean initVehicleStorySpawner(IsoMetaGrid.Zone zone, IsoChunk chunk, boolean debug) {
        VehicleStorySpawner vehicleStorySpawner = VehicleStorySpawner.getInstance();
        vehicleStorySpawner.clear();
        float _float = (float) (Math.PI / 6);
        if (debug) {
            _float = 0.0F;
        }

        Vector2 vector2 = IsoDirections.N.ToVector();
        vector2.rotate(Rand.Next(-_float, _float));
        vehicleStorySpawner.addElement("vehicle1", 0.0F, 1.0F, vector2.getDirection(), 2.0F, 5.0F);
        boolean _boolean = Rand.NextBool(2);
        vector2 = _boolean ? IsoDirections.E.ToVector() : IsoDirections.W.ToVector();
        vector2.rotate(Rand.Next(-_float, _float));
        vehicleStorySpawner.addElement("vehicle2", 0.0F, -2.5F, vector2.getDirection(), 2.0F, 5.0F);
        vehicleStorySpawner.setParameter("zone", zone);
        return true;
    }

    @Override
    public void spawnElement(VehicleStorySpawner spawner, VehicleStorySpawner.Element element) {
        IsoGridSquare isoGridSquare = element.square;
        if (isoGridSquare != null) {
            float _float = element.z;
            IsoMetaGrid.Zone zone = spawner.getParameter("zone", IsoMetaGrid.Zone.class);
            String string = element.id;
            switch (string) {
                case "vehicle1":
                    BaseVehicle baseVehicle1 = this.addVehicle(
                        zone, element.position.x, element.position.y, _float, element.direction, null, "Base.VanAmbulance", null, null
                    );
                    if (baseVehicle1 != null) {
                        this.addZombiesOnVehicle(Rand.Next(1, 3), "AmbulanceDriver", null, baseVehicle1);
                        ArrayList arrayList = this.addZombiesOnVehicle(Rand.Next(1, 3), "HospitalPatient", null, baseVehicle1);

                        for (int int0 = 0; int0 < arrayList.size(); int0++) {
                            for (int int1 = 0; int1 < 7; int1++) {
                                if (Rand.NextBool(2)) {
                                    ((IsoZombie)arrayList.get(int0)).addVisualBandage(BodyPartType.getRandom(), true);
                                }
                            }
                        }
                    }
                    break;
                case "vehicle2":
                    BaseVehicle baseVehicle0 = this.addVehicle(zone, element.position.x, element.position.y, _float, element.direction, "bad", null, null, null);
                    if (baseVehicle0 == null) {
                    }
            }
        }
    }
}
